package ManHinhChinh;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.beans.Statement;

import ManHinhChinh.TaoKetNoi;
public class ConnectSQL {
	
	
	public void DocSelect(String a,String b)
	{
		TaoKetNoi s = new TaoKetNoi();
		Connection con = s.TaoLienKet();
		java.sql.Statement stm;
		try {
			stm = con.createStatement();
			ResultSet rs = stm.executeQuery("SELECT "+a+ " FROM "+ b);
			while (rs.next())
				System.out.println(rs.getString("TenNhanVien"));
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void GhiINSERT2(String a, String b, String c, String d)
	{
		TaoKetNoi s = new TaoKetNoi();
		Connection con = s.TaoLienKet();
		java.sql.Statement stm;
		try {
			stm = con.createStatement();
			int rs = stm.executeUpdate("INSERT INTO [QuanLyMuaBanHangHoa].[dbo].[TAI_KHOAN]" +a+b+c+d+ ")");			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void GhiINSERTHangHoa(String a, String b, String c )
	{
		TaoKetNoi s = new TaoKetNoi();
		Connection con = s.TaoLienKet();
		java.sql.Statement stm;
		try {
			stm = con.createStatement();
			int rs = stm.executeUpdate("INSERT INTO [QuanLyMuaBanHangHoa].[dbo].[HANG_HOA] VALUES (N'"+a+"',N'"+b+"',N'"+c+"',0,0)");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
	}
	public void GhiThemKhachHang(String a, String b, String c, String d, String f)
	{

		TaoKetNoi s = new TaoKetNoi();
		Connection con = s.TaoLienKet();
		java.sql.Statement stm;
		try {
			stm = con.createStatement();
			int rs = stm.executeUpdate("INSERT INTO [QuanLyMuaBanHangHoa].[dbo].[KHACH_HANG] VALUES ('"+a+"','"+b+"','"+c+"','"+d+"','"+f+"')");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void GhiNhaCC(String a, String b, String c, String d, String f)
	{
		TaoKetNoi s = new TaoKetNoi();
		Connection con = s.TaoLienKet();
		java.sql.Statement stm;
		try {
			stm = con.createStatement();
			int rs = stm.executeUpdate("INSERT INTO [QuanLyMuaBanHangHoa].[dbo].[NHA_CUNG_CAP] VALUES (N'"+a+"',N'"+b+"',N'"+c+"',N'"+d+"',N'"+f+"')");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void GhiHoaDonBanLe(String a , String b, String c, String d)
	{
		TaoKetNoi s = new TaoKetNoi();
		Connection con = s.TaoLienKet();
		java.sql.Statement stm;
		try {
			stm = con.createStatement();
			int rs = stm.executeUpdate("INSERT INTO [QuanLyMuaBanHangHoa].[dbo].[HOA_DON_BAN_LE] VALUES (N'"+a+"',N'"+b+"',N'"+c+"',N	'"+d+"')");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
	
